package com.sxhuayuan.parking.listener;

import java.io.FileNotFoundException;

import javax.servlet.ServletContext;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
import org.springframework.util.ResourceUtils;
import org.springframework.web.context.ServletContextAware;

@Component
public class ApplicationContextListener implements ServletContextAware, ApplicationListener<ApplicationEvent> {

	Logger log = LoggerFactory.getLogger(getClass());

	@Override
	public void onApplicationEvent(ApplicationEvent event) {
		if (event instanceof ApplicationReadyEvent) {
			log.debug("application已启动...");
			try {
				log.info("项目classpath:" + ResourceUtils.getURL("classpath:").getPath());
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}
	}

	@Override
	public void setServletContext(ServletContext servletContext) {
		// TODO Auto-generated method stub

	}

}
